#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QSqlDatabase>

QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE

class OpenFile;
class QCheckBox;
class QLabel;
class QTableWidgetItem;

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = nullptr);
    ~MainWindow();

    void createMenu();

public slots:
    void onOpenFile();

    void onExit();

    void onOpenDB(const QString &fileName,const QString &pass);

    void onClickTables(const QModelIndex &index);

    void onQuery();
    void onExec();

    void onClearContent();

    void onRecordClick(int row,int column);
    void onRecordItemChanged(int row, int column);

protected:
    QString getCurrentTable() const;
    void innerRecordFullQuery(const QString &sql);

private:
    Ui::MainWindow *ui;

    QSqlDatabase m_db;

    QCheckBox *m_isAutoQuery = nullptr;
    QLabel *m_statusInfo = nullptr;

    OpenFile *m_openFileUI = nullptr;

    QAction *m_fileOpenAction = nullptr;
    QAction *m_fileExitAction = nullptr;
};
#endif // MAINWINDOW_H
